package io.coderyeah.ymcc.feign.fallback;

import feign.hystrix.FallbackFactory;
import io.coderyeah.ymcc.feign.client.CourseServiceClient;
import io.coderyeah.ymcc.result.JSONResult;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CourseClientFallback implements FallbackFactory<CourseServiceClient> {

    @Override
    public CourseServiceClient create(Throwable throwable) {
        return new CourseServiceClient() {
            @Override
            public JSONResult getCourseStateById(Long id) {
                throwable.printStackTrace();
                return JSONResult.error(throwable.getMessage());
            }

            @Override
            public JSONResult getCourseInfo(List<Long> ids) {
                throwable.printStackTrace();
                return JSONResult.error("下单服务异常");
            }
        };
    }
}
